package com.project.fiveCerealsSavoury.domain;

import java.sql.Timestamp;

import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;



/**
 * 交易记录
 * 
 * @author Administrator
 *
 */
public class Trade {
	/**
	 * id
	 */
	private Integer id;
	/**
	 * 初始金额
	 */
	@NotNull(message = "初始金额为零?")
	@Length(max = 20)
	private Double preMoney;
	/**
	 * 结算金额
	 */
	@NotNull(message = "结算金额为零?")
	@Length(max = 20)
	private Double aftMoney;
	/**
	 * 交易额
	 */
	@NotNull(message = "交易金额为零?")
	@Length(max = 20)
	private Double tradeMoney;
	/**
	 * 创建时间
	 */
	@NotBlank(message = "创建时间不为零")
	private Timestamp time;
	/**
	 * 用户名
	 */
	@NotBlank(message = "用户名不能为空")
	@Length(max = 20)
	private String name;
	/**
	 * 用户id
	 */
	@NotNull(message = "用户id不能为空")
	@Length(max = 20)
	private Integer userId;
	/**
	 * 类型
	 */
	@NotBlank(message = "类型不能为空")
	@Length(max = 20)
	private TradeStatus tradeStatus;
	/**
	 * 重量
	 */
	@NotNull(message = "重量不能为空")
	@Length(max = 20)
	private Double weight;
	/**
	 * 订单ID
	 */
	@NotNull(message = "订单id不能为空")
	private Integer orderId;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Double getPreMoney() {
		return preMoney;
	}

	public void setPreMoney(Double preMoney) {
		this.preMoney = preMoney;
	}

	public Double getAftMoney() {
		return aftMoney;
	}

	public void setAftMoney(Double aftMoney) {
		this.aftMoney = aftMoney;
	}

	public Double getTradeMoney() {
		return tradeMoney;
	}

	public void setTradeMoney(Double tradeMoney) {
		this.tradeMoney = tradeMoney;
	}

	public Timestamp getTime() {
		return time;
	}

	public void setTime(Timestamp time) {
		this.time = time;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}


	public TradeStatus getTradeStatus() {
		return tradeStatus;
	}

	public void setTradeStatus(TradeStatus tradeStatus) {
		this.tradeStatus = tradeStatus;
	}

	public Double getWeight() {
		return weight;
	}

	public void setWeight(Double weight) {
		this.weight = weight;
	}

	public Integer getOrderId() {
		return orderId;
	}

	public void setOrderId(Integer orderId) {
		this.orderId = orderId;
	}



	@Override
	public String toString() {
		return "Trade [id=" + id + ", preMoney=" + preMoney + ", aftMoney=" + aftMoney + ", tradeMoney=" + tradeMoney
				+ ", time=" + time + ", name=" + name + ", userId=" + userId + ", tradeStatus=" + tradeStatus
				+ ", weight=" + weight + ", orderId=" + orderId + "]";
	}

	


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((aftMoney == null) ? 0 : aftMoney.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((orderId == null) ? 0 : orderId.hashCode());
		result = prime * result + ((preMoney == null) ? 0 : preMoney.hashCode());
		result = prime * result + ((time == null) ? 0 : time.hashCode());
		result = prime * result + ((tradeMoney == null) ? 0 : tradeMoney.hashCode());
		result = prime * result + ((tradeStatus == null) ? 0 : tradeStatus.hashCode());
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		result = prime * result + ((weight == null) ? 0 : weight.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Trade other = (Trade) obj;
		if (aftMoney == null) {
			if (other.aftMoney != null)
				return false;
		} else if (!aftMoney.equals(other.aftMoney))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (orderId == null) {
			if (other.orderId != null)
				return false;
		} else if (!orderId.equals(other.orderId))
			return false;
		if (preMoney == null) {
			if (other.preMoney != null)
				return false;
		} else if (!preMoney.equals(other.preMoney))
			return false;
		if (time == null) {
			if (other.time != null)
				return false;
		} else if (!time.equals(other.time))
			return false;
		if (tradeMoney == null) {
			if (other.tradeMoney != null)
				return false;
		} else if (!tradeMoney.equals(other.tradeMoney))
			return false;
		if (tradeStatus != other.tradeStatus)
			return false;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		if (weight == null) {
			if (other.weight != null)
				return false;
		} else if (!weight.equals(other.weight))
			return false;
		return true;
	}

	/**
	 * 构造器
	 * @param id
	 * @param preMoney
	 * @param aftMoney
	 * @param tradeMoney
	 * @param time
	 * @param name
	 * @param userId
	 * @param tradeStatus
	 * @param weight
	 * @param orderId
	 */
	public Trade(Double preMoney, Double aftMoney, Double tradeMoney, Timestamp time, String name,
			Integer userId, TradeStatus tradeStatus, Double weight,Integer orderId) {
		super();
		this.preMoney = preMoney;
		this.aftMoney = aftMoney;
		this.tradeMoney = tradeMoney;
		this.time = time;
		this.name = name;
		this.userId = userId;
		this.tradeStatus = tradeStatus;
		this.weight = weight;
		this.orderId=orderId;
	}

	public Trade() {
		super();
		// TODO Auto-generated constructor stub
	}

	
}
